/**
 *
 */
package de.cbf.cam.dsa.services.impl.rcp_provider;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import de.cbf.cam.dsa.rcp.model.entities.MonthDSA;
import de.cbf.cam.dsa.rcp.model.entities.MonthDSAEnum;
import de.cbf.cam.dsa.services.interfaces.rcp_provider.IServiceDSAProviderMonths;
import de.cbf.cam.dsa.services.interfaces.rcp_provider.exceptions.EntityNotFoundException;
import de.cbf.util.uuidheader.entities.UUIDHeader;

/**
 * @author Surfer
 *
 */
public class ProviderMonthsDSA implements IServiceDSAProviderMonths {
	private static final String NAME = "Months Provider";
	private static ProviderMonthsDSA instance;

	protected List<MonthDSA> monthList = new ArrayList<MonthDSA>();

	private ProviderMonthsDSA(){
		initMonths();
	}

	public static ProviderMonthsDSA getInstance() {
		if(instance == null){
			instance = new ProviderMonthsDSA();
		}
		return instance;
	}

	@Override
	public UUIDHeader getEntityByItsID(UUID id) throws EntityNotFoundException {
		for (MonthDSA month : monthList) {
			if(month.getUuid().equals(id)){
				return month;
			}
		}
		throw new EntityNotFoundException("Month NOT found,id: "+id);
	}

	protected void initMonths(){
		monthList.clear();
		MonthDSA month;

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.PRAIOS);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.RONDRA);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.EFFERD);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.TRAVIA);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.BORON);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.HESINDE);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.FIRUN);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.TSA);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.PHEX);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.PERAINE);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.INGERIMM);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.RAHJA);
		monthList.add(month);

		month = new MonthDSA();
		month.setMonthEnum(MonthDSAEnum.NAMENLOS);
		monthList.add(month);
	}


	public List<MonthDSA> getMonthsDSA(){
		List<MonthDSA> resultList =  new ArrayList<MonthDSA>();
		resultList.addAll(monthList);
		return resultList;
	}

	@Override
	public String getName() {
		return NAME;
	}




}
